#include "parameterbtn.h"
#include "ui_parameterbtn.h"

ParameterBtn::ParameterBtn(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ParameterBtn)
{
    ui->setupUi(this);
    m_index = 0;
    ui->widget->installEventFilter(this);
}

ParameterBtn::~ParameterBtn()
{
    delete ui;
}

void ParameterBtn::setPicName(QString picStyle, QString name, int index)
{
     ui->labelPic->setStyleSheet(picStyle);
     ui->labelName->setText(name);
     m_TextName = name;
     n = index;
}

void ParameterBtn::setIndex(int index)
{
    m_index = index;
}

int ParameterBtn::getIndex()
{
    return m_index;
}

void ParameterBtn::setNormalStyle()
{
    ui->widget->setStyleSheet("border-image: url();");
}

void ParameterBtn::setClickedStyle()
{
    ui->widget->setStyleSheet("#widget{border-image: url(:/new/prefix1/Resource/ParTopRec.png);}");
}

bool ParameterBtn::eventFilter(QObject *watched, QEvent *event)
{
    if(event->type() == QEvent::MouseButtonPress)
    {
       emit sigClicked(m_TextName,n);
       setClickedStyle();
    }
    return false;
}
